package com.kaifamiao.convert;

import java.time.*;
import java.util.Date;

/**
 * 1、Date ----> LocalDateTime
 * 2、Date ----> LocalDate
 * 3、Date ----> LocalTime
 */
public class DateToLocalDateTime {

    public static void main(String[] args) {

        Date date = new Date();

        // Date -------> Instant
        Instant instant = date.toInstant();
        ZoneId zone = ZoneId.of( "Asia/Chongqing" );

        // Instant ------->  LocalDateTime
        LocalDateTime datetime = LocalDateTime.ofInstant( instant, zone );
        System.out.println( datetime );

        LocalDate localDate = datetime.toLocalDate();
        System.out.println( localDate );

        LocalTime localTime = datetime.toLocalTime();
        System.out.println( localTime );

    }

}
